package com.wuzhun.wxmp.controller.admin;

import com.wuzhun.wxmp.annotation.PageLoginRequired;
import com.wuzhun.wxmp.controller.BaseController;
import com.wuzhun.wxmp.util.CookieUtil;
import com.wuzhun.wxmp.util.DateTimeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author baolin
 * @date 2022/12/03 14:24 下午
 */
@Controller
@RequestMapping("/admin")
@Api("后台入口")
public class AdminMainController extends BaseController {

    @GetMapping("main")
    @ApiOperation("后台框架首页")
    @PageLoginRequired
    public ModelAndView main(HttpServletRequest httpServletRequest) {
        String username = CookieUtil.getCookie(httpServletRequest, "username");
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username", username);
        modelAndView.addObject("year", DateTimeUtil.getCurrentYear());
        return commonView(modelAndView, "admin/main");
    }
}
